<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    function show() {
      let pro = new Promise((resolve, reject) => {
        setTimeout(() => {
          // resolve("show()成功")
          reject("show()失败")
        }, 4000);
      })
      return pro;
    }
    function fn() {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve("fn()成功")
          // reject("fn()失败")
        }, 2000);
      })
    }

    //Promise的all, 参数为promise的数组, 所有异步函数执行完毕才返回数据
    Promise.all([show(), fn()]).then((results) => {
      console.log(results);
    }, errors => {
      console.log(errors);
    })





  </script>
</body>

</html>